# !/usr/bin/env python
# -*- coding:utf-8 -*-
# author:darkleo
# create Date:2016/12/4
import pygame
import time
class PlayUtil:

    def __init__(self,baiduMusic):
        self.baiduMusic = baiduMusic
        pygame.mixer.init()

    def play(self,song_id):
        abs_file_path = self.baiduMusic.download_song(song_id)
        print("play song ID:%s song music address:%s" % (song_id, abs_file_path))
        print(abs_file_path)
        pygame.mixer.music.load(abs_file_path)
        # 设置播放结束事件
        pygame.mixer.music.set_endevent()
        pygame.mixer.music.play()
        print("end_event1-->", pygame.mixer.music.get_endevent())
        while True:
            time.sleep(30)
            print("end_event-->", pygame.mixer.music.get_endevent())
